<?php

/**
 * This is the model class for table "mobilefile".
 *
 * The followings are the available columns in table 'mobilefile':
 * @property string $id
 * @property string $version
 * @property integer $type
 * @property string $filePath
 * @property string $addTime
 */
class Mobilefile extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Mobilefile the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'MobileFile';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('filePath',   
			    'file',   
			    'allowEmpty'=>true,  
			    //'types'=>'txt',  
			    'maxSize'=>1024 * 1024 * 40,  
			    'tooLarge'=>'文件最大不超过4MB，请重新上传!',  
			),  
			array('version, type, filePath', 'required'),
			array('type', 'numerical', 'integerOnly'=>true),
			array('version', 'length', 'max'=>100),
			array('filePath', 'length', 'max'=>64),
			array('addTime', 'safe'),
			array('id, version, type, filePath, addTime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'version' => '对上传文件的描述',
			'type' => '版本类型',
			'filePath' => '上传的文件',
			'addTime' => '添加时间',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('version',$this->version,true);
		$criteria->compare('type',$this->type);
		$criteria->compare('filePath',$this->filePath,true);
		$criteria->compare('addTime',$this->addTime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}